stack = [0]
i = 0

while True:
    state = stack[-1]
    a = input[i]
    
    action = ACTION[state][a]
    
    if action == 'shift':
        stack.append(a)
        stack.append(GOTO[state][a])
        i += 1
    
    elif action is 'reduce A → β':
        for _ in range(2 * len(β)):
            stack.pop()
        top = stack[-1]
        stack.append(A)
        stack.append(GOTO[top][A])
    
    elif action == 'accept':
        print("Success")
        break
    
    else:
        print("Error")
        break